import com.entity.Poker;
import com.entity.PokerType;
import com.entity.StrategyExecutor;
import com.group.*;
import com.mike.median.util.PokerList;
import com.mike.median.util.PokerUtil;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class main {
    private static List<StrategyExecutor> executorChain = new ArrayList<>();
    private static PokerList<Poker> pokers = new PokerList<>();

    static {
        //牌组初始化
        for (int i = 2; i <= 14; i++) {
            for (Poker.TYPE_ENUM type_enum : Poker.TYPE_ENUM.values()) {
                Poker poker = new Poker(i, type_enum);
                pokers.add(poker);
            }
        }
        //策略算法链表初始化
        StrategyExecutor straightFlush = new StrategyExecutor(new StraightFlushStrategy(), 1);
        StrategyExecutor fourOfKind = new StrategyExecutor(new FourOfKindStrategy(), 2);
        StrategyExecutor fullHouse = new StrategyExecutor(new FullHouseStrategy(), 3);
        StrategyExecutor flush = new StrategyExecutor(new FlushStrategy(), 4);
        StrategyExecutor straight = new StrategyExecutor(new StraightStrategy(), 5);
        StrategyExecutor threeOfKind = new StrategyExecutor(new ThreeOfKindStrategy(), 6);
        StrategyExecutor twoPair = new StrategyExecutor(new TwoPairStrategy(), 7);
        StrategyExecutor pair = new StrategyExecutor(new PairStrategy(), 8);
        StrategyExecutor normal = new StrategyExecutor(new NormalStrategy(), 9);
        executorChain.add(straightFlush);
        executorChain.add(fourOfKind);
        executorChain.add(fullHouse);
        executorChain.add(flush);
        executorChain.add(straight);
        executorChain.add(threeOfKind);
        executorChain.add(twoPair);
        executorChain.add(pair);
        executorChain.add(normal);
        Collections.sort(executorChain);
    }

    public static void main(String[] args) {
        //发牌
        List<PokerType> pokerTypes = new ArrayList<>();
        for (int j = 0; j < 20; j++) {
            Collections.shuffle(pokers);
            PokerList<Poker> handPokers = new PokerList<>();
            for (int i = 0; i < 5; i++) {
                handPokers.add(pokers.get(i));
            }
            //牌型分类计算
            PokerType pokerType = PokerUtil.getPokerType(executorChain, handPokers);
            pokerTypes.add(pokerType);
        }
        //排序
        Collections.sort(pokerTypes);
        System.out.println("================================================================================排序后================================================================================");
        for(PokerType pokerType:pokerTypes){
            System.out.println(pokerType);
        }
    }
}
